/**
 * 
 * @Project HRL Simulation
 * @Date 20.06.2011
 * @Author Aebi Pascal, Kocher Marc, Sriranjan George
 * @School BFH-TI Biel, Projekt 1
 *
 */

package gui.objects3D;

import javax.media.j3d.Appearance;
import javax.media.j3d.ImageComponent2D;
import javax.media.j3d.Texture;
import javax.media.j3d.Texture2D;
import com.sun.j3d.utils.geometry.Box;
import com.sun.j3d.utils.geometry.Primitive;
import com.sun.j3d.utils.image.TextureLoader;

/**
 * The Class Load3D.
 */
public class Load3D extends Box{
	
	/** The constants for the dimensions of the loads. */
	public static final float LOADWIDTH  = 1.0f;
	public static final float LOADLENGTH = 1.0f;
	public static final float LOADHEIGHT = 1.0f;
	/** The constant for the the primflags. */
	private static int primflags = Primitive.GENERATE_NORMALS + Primitive.GENERATE_TEXTURE_COORDS;
	
	
	/**
	 * Instantiates a new Load3D object.
	 * 
	 */
	public Load3D(){
		super(LOADLENGTH/2, LOADHEIGHT/2, LOADWIDTH/2, primflags, null);	
		this.setAppearance(createAppearance());
	}
	
	
	/**
	 * Create appearance.
	 * 
	 * @return the appearance
	 */
	private Appearance createAppearance() {
		Appearance app = new Appearance();
		TextureLoader loader = new TextureLoader("resources/textures/load.jpg", null);
		ImageComponent2D image = loader.getImage();
		Texture2D texture = new Texture2D(Texture.BASE_LEVEL, Texture.RGBA, image.getWidth(), image.getHeight());
		texture.setImage(0, image);
		app.setTexture(texture);
		return app;
	}
}
